package com.atguigu4.search_sort.exer2;

/**
 * ClassName: arrary_xianxichazhao
 * Description:
 *int[] arr1 = new int[]{34,54,3,2,65,7,34,5,76,34,67};
 * 查找元素5是否在上述数组中出现过？如果出现，输出对应的索引值。
 * @Author liu
 * @Create 2024/8/12 20:11
 * @Version 1.0
 */

public class arrary_xianxichazhao {
    public static void main(String[] args) {
        int[] arr1 = new int[]{34,54,3,2,65,7,34,5,76,34,67};
        //查找元素5是否在上述数组中出现过
        boolean flag = true;
        int num = 87;
        for (int i = 0; i <arr1.length ; i++) {
            if(num == arr1[i]){
                System.out.print("找到了，"+"在第"+i+"位");
                flag = false;
                break;
            }

        }
        if(flag) {
            System.out.print("抱歉，没有该数");
        }

    }
}
